package ui;

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

/**
 * 메인 프레임
 * rh2wy4Tz2Cs3
 */
public class Main extends JFrame
{
	public static boolean debugMode;

	private Container pane = getContentPane();
	private MainMap mainMap = new MainMap(this);
	private MiniMap miniMap = new MiniMap(mainMap);

	/**
	 * 생성자
	 */
	public Main()
	{
		pane.setLayout(null);
		pane.setBackground(Color.BLACK);

		pane.add(miniMap);
		pane.add(mainMap);

		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setScreen(true, 1024, 768);
		setVisible(true);
		setTitle("자바 포트리스 20614 엄민석, 20619 이형호");

		addKeyListener(new KeyListener()
		{
			public void keyPressed(KeyEvent e)
			{
				switch (e.getKeyCode())
				{
				case KeyEvent.VK_UP:
					repaint();
					break;
				case KeyEvent.VK_DOWN:
					repaint();

					break;
				case KeyEvent.VK_LEFT:

					break;
				case KeyEvent.VK_RIGHT:

					break;
				}

			}

			public void keyReleased(KeyEvent e)
			{
			}

			public void keyTyped(KeyEvent e)
			{
			}
		});
	}

	/**
	 * 윈도우의 크기를 설정하는 메서드
	 * @param bFull  : 전체화면 여부
	 * @param width  : 너비
	 * @param height : 높이
	 */
	public void setScreen(boolean bFull, int width, int height)
	{
		DisplayMode dm;
		GraphicsConfiguration gc;
		GraphicsDevice gd;
		GraphicsEnvironment ge;
		dm = new DisplayMode(width, height, 32, DisplayMode.REFRESH_RATE_UNKNOWN);
		ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
		gd = ge.getDefaultScreenDevice();
		gc = gd.getDefaultConfiguration();

		if (bFull)
		{
			if (gd.isFullScreenSupported())
			{
				gd.setFullScreenWindow(this);
				if (gd.isDisplayChangeSupported())
				{
					gd.setDisplayMode(dm);
					return;
				}
			}
		}
		gd.setFullScreenWindow(null);
		setSize(width, height);
	}

	/**
	 * 프로그램의 시작점
	 * @param args : 명령행 인수
	 */
	public static void main(String[] args)
	{
		debugMode = false;
		new Main();
	}
}
																